home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / cexppw.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  2KB  |  67 lines

  1. {$X+,B-,V-} {essential compiler directives}
  2.  
  3. Program CexpPw;
  4.  
  5. { Example for the nwConn unit / NwTP 0.6 API. (c) 1993,1995, R. Spronk }
  6.  
  7. { Andre Middendorp [2:512/220] wrote on Sun 3 Jul 94
  8.  
  9. Q: Ik ben op zoek naar een tooltje waarmee ik op een NW 3.1x server
  10.    een file aan kan maken met daarin alle gebruikers waarvan het
  11.    wachtwoord is vervallen. Wie weet iets....?
  12.  
  13. A: Here's a short program that will check whether or not the password
  14.    has expired of any user object. It will present you with a list of
  15.    all accounts that are expired.}
  16.  
  17. Uses nwMisc,nwBindry,nwConn,nwServ;
  18.  { nwServ used for GetFileServerDateAndTime only }
  19.  
  20. { Demonstates the GetObjectLoginControl function.
  21.   see also the information provided with the ObjectCanLoginAt call }
  22.  
  23. Var TimeNow         :TnovTime;
  24.     lastObjSeen     :Longint;
  25.     RepName         :String;
  26.     RepType         :Word;
  27.     RepId           :LongInt;
  28.     RepFlag         :Byte;
  29.     RepSecurity     :Byte;
  30.     RepHasProperties:Boolean;
  31.     LogControlInfo  :TloginControl;
  32.     NbrOfExp        :word;
  33. Begin
  34. Writeln('CEXPPW: Check Expired Passwords.');
  35. IF NOT (IsShellLoaded and IsUserLoggedOn)
  36.  then begin
  37.       writeln('Load network shell and logon before running this program');
  38.       halt(1);
  39.       end;
  40.  
  41. GetFileServerDateAndTime(TimeNow);
  42.  
  43. NbrOfExp:=0;
  44. lastObjSeen:=-1;
  45. WHILE
  46. ScanBinderyObject('*',OT_USER,lastObjSeen,
  47.                   RepName, RepType, RepId,
  48.                   RepFlag, RepSecurity, RepHasProperties)
  49.  do begin
  50.     IF GetObjectLoginControl(RepName,RepType,LogControlInfo)
  51.      then with LogControlInfo.AccountExpirationDate
  52.            do if (year>0) { year=0: no expiration date was set }
  53.                  and (TimeNow.year>=year)
  54.                  and (TimeNow.month>=month)
  55.                  and (TimeNow.day>=day)
  56.                then begin
  57.                     writeln('Account of ',Repname,' expired on: ',day,'/',month,'/',year);
  58.                     inc(NbrOfExp);
  59.                     end;
  60.     end;
  61. if nwBindry.Result<>$FC { NO_SUCH_OBJECT, indicates end of search }
  62.  then writeln('Error scanning bindery : $',HexStr( nwBindry.Result,2));
  63. if NbrOfExp=0
  64.  then writeln(#10#13,'No expired passwords found.')
  65.  else writeln('(dates expressed in dd/mm/yy format.');
  66. end.
  67.